<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox-content">
					<form class="form-horizontal m-t" id="signupForm">
						<input id="id" name="id" th:value="${scgl.id}"
							type="hidden">
							<input id="code" name="code" th:value="${scgl.code}"
							type="hidden">
					<div class="form-group">
							<label class="col-sm-3 control-label">类型：</label>
							<input id="sclb" name="sclb" th:value="${scgl.sclb}"type="hidden">
							<div class="col-sm-8">
								<select id="selectTest" name="selectTest" onchange="gradeChange()">
										<option value="0">小程序</option>
										<option value="1">图文</option>
										<option value="2">文本</option>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">标题：</label>
							<div class="col-sm-8">
								<input id="title" name="title" th:value="${scgl.titile}" class="form-control" type="text">
							</div>
							
							<label class="col-sm-3 control-label">素材图片：</label>
							<div class="col-sm-8">
								 <input id="url" name="url" th:value="${scgl.url}"  class="form-control"
									 type="hidden"> 
									<button type="button" id="test1" class="btn btn-danger faupload dz-clickable" data-input-id="c-smallimage" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-smallimage" initialized="true"><i class="fa fa-upload dz-message"></i> 上传</button>
					                 <div class="col-sm-11" id="newsImg">
                                			<img th:src="${scgl.url}" height='100' width='100'>
									</div> 
					                
							</div>
							
							<label class="col-sm-3 control-label">小程序路径：</label>
							<div class="col-sm-8">
								<input id="appUrl" name="appUrl"th:value="${scgl.appUrl}"  class="form-control" type="text"
									>
							</div>
							
							<label class="col-sm-3 control-label">跳转路径：</label>
							<div class="col-sm-8">
								<input id="ymlj" name="ymlj" th:value="${scgl.ymlj}" class="form-control" type="text"
									>
							</div>
						</div>
						
						
						
						<div class="form-group">
								<input id="content" name="content" type="hidden"> <label
									class="col-sm-1 control-label">描述：</label>
								<div class="col-sm-11">
									<div class="ibox-content no-padding">
										<textarea rows="10" cols="60" id="content_sn" th:text="${scgl.scms}" class="summernote"></textarea>
									</div>
								</div>
							</div> 
						<div class="text-right form-group">
								<a class="btn btn-default waves-effect waves-light"
									onclick="returnList()">返回列表</a>
								<button type="button"
									class="btn btn-primary waves-effect waves-light"
									onclick="save()">保存</button>
							</div>
					</form>
				</div>
			</div>
		</div>
	</div>
	<div th:include="include::footer"></div>
	<script type="text/javascript" src="/js/appjs/config/qbEdit.js">
	</script>
	<script type="text/javascript">
	
	$(function () {
		var sclb=$('#sclb').val();
		$("#selectTest option[value= "+sclb+"]").attr("selected", "selected");
	});
	
	var gzhId = $('#gzhId').text();
	var media_id;
	var url;
	 layui.use('upload', function () {
    var upload = layui.upload;
    //执行实例
    var uploadInst = upload.render({
        elem: '#test1', //绑定元素
        url: '/common/sysFile/upload2', //上传接口
        size: 1000,
        data: {"gzhId":gzhId},
        accept: 'file',
        done: function (r) {
        	console.log(r);
        	media_id=r.media_id;
        	url=r.fileName;
            layer.msg(r.msg);
            $("#url").val("");
            $("#url").val(r.fileName);
            $("#code").val("");
            $("#code").val(r.media_id);
            $("#newsImg").html("");
            $("#newsImg").append(" <img src='"+r.fileName+"' alt='...' height='100' width='100'>" );
        },
        error: function (r) {
            layer.msg(r.msg);
        }
    });
});
	
	
	/* $('.summernote').summernote({
		height : '220px',
		lang : 'zh-CN',
		callbacks: {
            onImageUpload: function(files, editor, $editable) {
                sendFile(files);
            }
        }
	}); */
    function save() {
    	//var rwsm=editor.html();
    	var scnr = $("#content_sn").val();
    	var title = $("#title").val();
    	var sclb = $("#selectTest").val();
    	var id = $("#id").val();
    	var url33 = $("#url").val();
    	var appUrl = $("#appUrl").val();
    	var ymlj = $("#ymlj").val();
    	$.ajax({
	        type: 'post',
	        url: '/config/gzhConfig/msgUpdate',
	        data: {id:id,titile: title,url:url33,gzhId:gzhId,scms:scnr,code:media_id,type:0,sclb:sclb,appUrl:appUrl,ymlj:ymlj},
	        success: function(data){
	        	if(data.code == 0){
	        		parent.layer.msg("操作成功");
					parent.reLoad();
					var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
					parent.layer.close(index);
				} else {
					parent.layer.alert(data.msg)
				}
	        }
	    });
    	
    }
</script>
</body>
</html>
